You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

20 lines
615 B

import { oauthManager } from '#server/service/oauth/oauth-manager';
import { createAuthContext } from '#server/service/auth/context';
export default defineWrappedResponseHandler(async (event) => {
const { getCurrent } = createAuthContext(event);
const user = await getCurrent();
const providerName = getRouterParam(event, 'provider');
if (!providerName) {
throw createError({
statusCode: 400,
statusMessage: 'Provider is required',
});
}
const userId = user?.id;
const authUrl = oauthManager.getAuthorizationUrl(providerName, userId);
return sendRedirect(event, authUrl);
});